<template>
  <template v-for="item in btnList" :key="`${item.eventName}${+new Date()}`">
    <a-button
      class="btnItem"
      :disabled="disabled"
      :type="item.btnType || 'primary'"
      :status="item.status"
      @click="handleEvent(item.eventName)"
    >
      <template v-if="item.type" #icon>
        <span :class="'iconfont ' + item.type"></span>
      </template>
      <template #default>{{ item.name }}</template>
    </a-button>
  </template>
</template>
<script setup>
import { toRefs } from 'vue'
/***
 * 使用
 */
const props = defineProps({
  btnList: {
    type: Array,
    default: () => [
      {
        name: '',
        type: '', //icon
        eventName: '',
        status: '', //按钮颜色
      },
    ],
  },
  disabled: {
    type: Boolean,
    default: false,
  },
})
const emit = defineEmits(['handleBtnClick'])
const { btnList } = toRefs(props)
const handleEvent = (type) => {
  if (!type) return
  emit('handleBtnClick', type)
}
</script>
